package Test;

import javax.swing.JPanel;

import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.JTextArea;
import javax.swing.JLabel;

import java.awt.Color;

public class Output extends JPanel {
	private JTextArea textArea;
	private JLabel lblNewLabel;
	
	Data6 [] d;
	/**
	 * Create the panel.
	 */
	public Output() {
		setLayout(new BorderLayout(0, 0));
		add(getTextArea(), BorderLayout.CENTER);
		add(getLblNewLabel(), BorderLayout.NORTH);

	}
	private JTextArea getTextArea() {
		if (textArea == null) {
			textArea = new JTextArea();
			textArea.setBackground(Color.LIGHT_GRAY);
		}
		return textArea;
	}
	private JLabel getLblNewLabel() {
		if (lblNewLabel == null) {
			lblNewLabel = new JLabel("이름 성별 나이");
		}
		return lblNewLabel;
	}
	public void setD(Data6[] d){
		this.d=d;
		
		textArea.setText(""); // 모든 데이터 삭제
		for(int i=0;i<d.length;i++){
			if(d[i] == null) continue;
			String str = String.format("%-8s %6d %-10s",d[i].name,d[i].sex,d[i].age);
			textArea.append(str);
			textArea.append("\n");
			
		}
	}
}
